// cssPacker.js sept, 05, 2012, http://gubhugreyot.blogspot.com
function compressCSS() {
	var code=document.getElementById('fileInput').value;
	var box=document.getElementById('sizeInput');
	box.value=code.length;
}
function runCompression() {
	compressCSS();
	var code=document.getElementById('fileInput').value;
	var commentRegex='';
	if (document.getElementById("commentsCSS").checked) {
		commentRegex='\\/\\*.*?\\*\\/';
	}
	if (''!=commentRegex) {
		commentRegex=new RegExp(commentRegex ,'g');
		code=code.replace(commentRegex, '');
	}
	code=code.replace(/\n*/g, '');
	code=code.replace(/[	 ]+/g, ' '); 
	code=code.replace(/\s?([;:{},+>])\s?/g, '$1');
	if (document.getElementById("perSyntax").checked) {
		code=code.replace(/}/g, "}\n");
	}
	document.getElementById('sizeOutput').value=code.length;
	var codeOutBox=document.getElementById('fileOutput');
	codeOutBox.value=code;

	var compressionRatio=code.length/document.getElementById('sizeInput').value*100;
	compressionRatio=100-compressionRatio;
	compressionRatio=Math.round(compressionRatio*100)/100;
	document.getElementById('compressValue').value=compressionRatio+'%';
}